Skip to content

feat: support sys-minimal feature#5621

Merged
Arshia001 merged 3 commits intowasmerio:mainfrom
hardfist:wasi-common
Jul 7, 2025
Merged

feat: support sys-minimal feature#5621
Arshia001 merged 3 commits intowasmerio:mainfrom
hardfist:wasi-common

Conversation

@hardfist
Copy link
Contributor

@hardfist hardfist commented Jul 7, 2025

This pull request introduces support for the sys-minimal feature in the wasix library, provide minimal sys implementation to reduce binary size for consumers.
Related to

@syrusakbary I'm not sure how I should add tests about this, may need your guidance

@hardfist hardfist marked this pull request as ready for review July 7, 2025 06:35
@hardfist
Copy link
Contributor Author

hardfist commented Jul 7, 2025

@promptless
Copy link

promptless bot commented Jul 7, 2025

📝 Documentation updates detected!

New suggestion: Document wasi-common feature for WASIX library

@syrusakbary
Copy link
Member

Hey @hardfist,
I see you introduced the wasi-common feature, but it doesn't do any code restrictions at all that would decrease the code size.
Ideally, we would see some systemcalls being restricted/not added on the WASI lib.rs file, which would let the compiler optimize the not-used code away.

Also, You made the wasi-common feature being xor'ed with js or sys which doesn't make that much sense. wasi-common should/could be used with either js or sysm

@Arshia001
Copy link
Member

Arshia001 commented Jul 7, 2025

Hey @hardfist, thank you for this contribution!

From what I can tell, the change adds a new feature, which disables some of the dependencies. I have doubts about the exact set of dependencies enabled, though. For example, disabling the host networking feature isn't 100% compatible with wasip1, as with wasip1, you do get networking, just not the ability to open new sockets.

Since the set of features enabled in the wasi-common feature is not something that aligns 100% with wasip1, I wonder if it'd be better to just enable just these features in your own crate that depends on wasmer-wasix? I understand this is not possible today because we refuse to compile without exactly one of the sys or js features, so my suggestion is:

  • we revert this change
  • instead, we add in a new feature, named sys-minimal, which will be equivalent to "enable native stuff such as state::handles::globals, but nothing else"
  • sys and sys-minimal can both be active at the same time, since they don't clash in any way, but if at least one is enabled, js must be disabled. Also, at least one of js or (sys/sys-minimal) must be enabled for the crate to compile.
    • This is, BTW, another issue with the current implementation; you can, for example, have wasi-common and js active at the same time and not trigger the compile errors
  • client crates can then enable sys-minimal and cherry pick any other features they need, leaving out unused ones to avoid code bloat.

Would this solve your usecase, @hardfist?

@hardfist
Copy link
Contributor Author

hardfist commented Jul 7, 2025

The wasi-common semantic I want is actually the same as @Arshia001 's suggestion of sys-minimal(I use wasi-common just because wasmtime use this naming 🤣), so @Arshia001 your suggestion would be perfect for my case.

I see you introduced the wasi-common feature, but it doesn't do any code restrictions at all that would decrease the code size.

I think it can reduce the binary size cause it doesn't enforce all features sys and js do, so consumer can pick minimal feature

@Arshia001
Copy link
Member

Cool! Do you want to make the implementation?

@hardfist
Copy link
Contributor Author

hardfist commented Jul 7, 2025

Cool! Do you want to make the implementation?

yeah, I can give it a second try

@hardfist hardfist changed the title feat: support wasi-common feature feat: support sys-minimal feature Jul 7, 2025
@Arshia001 Arshia001 self-requested a review July 7, 2025 07:56
@Arshia001
Copy link
Member

LGTM now!

@hardfist
Copy link
Contributor Author

hardfist commented Jul 7, 2025

@Arshia001 I also notice that some of wasmer's dependency is not necessary for our case like wat and wonder whether it could be feature gated too like wasix, if so I can continue improve in following PR

@hardfist
Copy link
Contributor Author

hardfist commented Jul 7, 2025

@Arshia001 it seems these failing tests is not related to the change?

@Arshia001
Copy link
Member

@hardfist I'm quite sure we already have a wat feature in wasmer. I remember it having a sizable impact on binary size.

The integration tests are flaky, and hence not marked as required. Merging this in. Thanks again!

@Arshia001 Arshia001 merged commit cf8aa38 into wasmerio:main Jul 7, 2025
81 of 84 checks passed
@hardfist
Copy link
Contributor Author

hardfist commented Jul 8, 2025

@Arshia001 sorry to bother, when will wasmer release next version?

@Arshia001
Copy link
Member

I don't have an exact time, but 6.1 is coming soon, probably as soon as the current work on dynamic linking is done, which is very close to the finish line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants